.section .text, "ax"

/**
 * function [ mx_atom_swp ] implementation
 * @prototype: mx_usize_t mx_atom_swp (mx_usize_t newv, volatile mx_usize_pt var);
 */
.global mx_atom_swp
.type mx_atom_swp, "function"
mx_atom_swp:
    stp x3, x2, [sp, #-16]!
    mov x2, x0          // x2 = newv
    swp x2, x0, [x1]    // x0 = *var && *var = x2
    ldp x3, x2, [sp], #16
    ret                 // return x0
